package br.com.SAM.Bean;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import br.com.SAM.Interfaces.IPaciente;
import br.com.SAM.modelos.Paciente;

@Stateless
public class PacienteBean extends GenericBean implements IPaciente {
	@PersistenceContext(unitName="sam")
	private EntityManager em;

	public Paciente findByCns(String cns) {
		Query q = em.createNamedQuery("pessoa.findByCns");
		q.setParameter("param", cns);
		
		try {
			return (Paciente) q.getSingleResult();
		} catch (NoResultException e) {
			return null;
		}
		
		
	}

	

}
